<template>
	<view class="bankCardM">
		<block v-for="(item,index) in dataList" :key="index">
			
			<view class="bank-item" @longtap="longTap(item.bank_name,item.bankid)" :style="'background: url(' + item.logo + ') no-repeat center;background-size: cover;'">
				<view class="one">
					{{item.bank_name}}
				</view>
				<view class="two">
					储蓄卡
				</view>
				<view class="three">
					{{item.bankcard}}
				</view>
			</view>
		</block>



		<view class="card" @click="navTo('/pages/set/bandingBankCard')">
			<text class="iconfont font1">&#xe641;</text>
			<text class="font2">绑定其他银行卡</text>
			<text class="iconfont font3">&#xe600;</text>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				dataList: [],
				dataList1: [{
						bgc: '/static/imgs/public/bankCard01.png',
						name: '建设银行',
						type: '储蓄卡',
						idNumber: '**** 0000'
					},
					{
						bgc: '/static/imgs/public/bankCard02.png',
						name: '招商银行',
						type: '储蓄卡',
						idNumber: '**** 0000'
					},
					{
						bgc: '/static/imgs/public/bankCard03.png',
						name: '农业银行',
						type: '储蓄卡',
						idNumber: '**** 0000'
					}

				]
			};
		},
		onShow() {
			this.getData();
		},
		methods: {
			longTap(bankname, id) {
				var _self = this;
				uni.showModal({
					content: `是否要删除~${bankname}~`,
					success(e) {
						
						if(e.confirm){
							_self.delBank(id);
							setTimeout(() => {
								_self.getData();
							},500)
						}
					},
				})
			},
			async delBank(id) { // 删除银行卡
				let a = await this.$http.delBank({
					bankid: id
				});
				uni.showToast({
					title: a.message,
					icon: 'none'
				})
			},
			navTo(url) {
				uni.navigateTo({
					url
				});
			},
			async getData() {
				let a = await this.$http.getBankCard();
				this.dataList = a.data
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import 'static/css/smallCommon.scss';
</style>
